package net.techwatch.guava.collect;

import java.util.Collection;
import java.util.HashSet;

public class InstrumentedHashSet<E> extends HashSet<E> {

	private int count = 0;
	
	@Override
	public boolean add(E e) {
		count++;
		return super.add(e);
	}

	@Override
	public boolean addAll(Collection<? extends E> c) {
		count += c.size();
		return super.addAll(c);
	}

	@Override
	public boolean remove(Object o) {
		count--;
		return super.remove(o);
	}

	@Override
	public boolean removeAll(Collection<?> c) {
		count -= c.size();
		return super.removeAll(c);
	}

	public int count() {
		return this.count;
	}
}
